package org.example.aop.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//动态代理
public class JDKInvocationHandler implements InvocationHandler {

//    private HouseSubject houseSubject;
    //太狭隘，写Object
    private Object target;

    public JDKInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我是中介，我要开始出租房子了（动态代理）");
        Object result = method.invoke(target,args);
        System.out.println("我是中介，我的代理结束了（动态代理）");
        return result;
    }
}
